package com.itheima.mapper;

import com.itheima.annotation.Syslog;
import com.itheima.pojo.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 部门管理
 */
@Mapper
public interface DeptMapper {

    /**
     * Select list list.
     *
     * @return the list
     */

    @Select("select * from dept")
    List<Dept> selectList();

    /**
     * Delete by id.
     *
     * @param id the id
     */
    @Syslog
    @Delete("delete from dept where id = #{id};")
    void deleteById(Integer id);

    /**
     * Save.
     *
     * @param dept the dept
     */
    @Syslog
    @Insert("insert into dept (name,create_time,update_time) values (#{name},#{createTime},#{updateTime})")
    void save(Dept dept);

    /**
     * Select count by name integer.
     *
     * @param name the name
     * @return the integer
     */
    @Select("select count(*) from dept  where name = #{name}")
    Integer selectCountByName(String name);

    /**
     * Select dept by id dept.
     *
     * @param id the id
     * @return the dept
     */
    @Select("select * from dept where id = #{id}")
    Dept selectDeptById(Integer id);

    /**
     * Update dept.
     *
     * @param dept the dept
     */
    @Update("update dept set name = #{name},create_time = #{createTime}, update_time=#{updateTime} where id = #{id}")
    void updateDept(Dept dept);

    @Select("select * from dept where name = #{name}")
    Integer selectDeptExists(String name);

}
